package com.yanqu.road.server.timer.iceServer;

import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.iceservergift.IceServerGiftModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.utils.executor.GeneralTask;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class IceServerGiftSendRewardTask extends GeneralTask {

    private static Logger logger = LogManager.getLogger(IceServerGiftSendRewardTask.class);

    private static boolean running = false;

    @Override
    public void doRun() {
        if (!running) {
            running = true;
            try {
                for (GamePlayer player : GamePlayerMgr.getAllOnlinePlayer()) {
                    player.getModule(IceServerGiftModule.class).autoSendIceServerGiftReward();
                }
            } catch (Exception e) {
                logger.error("autoSendIceServerGiftReward error. ", e);
            } finally {
                running = false;
            }
        }
    }
}